package com.xunlai.infra.permission.manager.authority.login;

import jakarta.servlet.http.HttpServletRequest;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.Authentication;

import java.util.*;

@Slf4j
@Data
@RequiredArgsConstructor
public class JwtTokenResponseBodyAuthenticationSuccessHandler extends AbstractResponseBodyAuthenticationSuccessHandler {

    @Override
    protected void handleSuccessInternal(HttpServletRequest request, Authentication authentication) {
//        TenantUser principal = (TenantUser) authentication.getPrincipal();
//        Collection<? extends GrantedAuthority> authorities = authentication.getAuthorities();
//        authentication.isAuthenticated();
//        SecurityContextHolder.
//        SecurityContextHolder.getContext().setAuthentication(authentication);
//        request.getSession().setAttribute("loginUser",principal);
    }

    @Override
    protected Object successBody(HttpServletRequest request, Authentication authentication) {
        Map<String,String> tokenMap = new HashMap<>(2);
        tokenMap.put("token","1");
        return tokenMap;
    }



    private static final String MOBILE_PATTERN = "^[1](([3|5|8][\\\\d])|([4][4,5,6,7,8,9])|([6][2,5,6,7])|([7][^9])|([9][1,8,9]))[\\\\d]{8}$";

    private static final String EMAIL_PATTERN = "^[A-Za-z0-9._%'-]+@[A-Za-z0-9.-]+\\.[a-zA-Z]{2,4}$";

    private static final String ID_CARD_PATTERN = "(^[1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$)|(^[1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}$)";



}
